#include "ConnectionConfiguration.h"

ConnectionConfiguration::ConnectionConfiguration(std::string & serviceName) {
	init(serviceName, 5222, serviceName);
}

ConnectionConfiguration::ConnectionConfiguration(std::string & host, int port, std::string & serviceName) {
    init(host, port, serviceName);
}

ConnectionConfiguration::ConnectionConfiguration(std::string & host, int port) {
    init(host, port, host);
}

void ConnectionConfiguration::init(std::string & host, int port, std::string & serviceName) {
    this->host = host;
    this->port = port;
    this->serviceName = serviceName;
	securityMode = ENABLED;

    // Build the default path to the cacert truststore file. By default we are
    // going to use the file located in $JREHOME/lib/security/cacerts.
	/*
    std::string javaHome = System.getProperty("java.home");
    StringBuilder buffer = new StringBuilder();
    buffer.append(javaHome).append(File.separator).append("lib");
    buffer.append(File.separator).append("security");
    buffer.append(File.separator).append("cacerts");
	*/
#ifdef _WIN32
    truststorePath = "C:/";//buffer.toString();
#else
    truststorePath = "~";//buffer.toString();
#endif
    // Set the default store type
    truststoreType = "jks";
    // Set the default password of the cacert file that is "changeit"
    truststorePassword = "changeit";
}

void ConnectionConfiguration::setLoginInfo(std::string & username, std::string & password, std::string & resource, bool sendPresence) {
	this->username = username;
    this->password = password;
    this->resource = resource;
    this->sendPresence = sendPresence;
}

